//
//  District.m
//  07-homework
//
//  Created by dllo on 16/7/12.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "District.h"

@implementation District
- (instancetype)initWithName:(NSString *)name {
        return [self initWithName:name number:nil];
}
+ (instancetype)AreaWithName:(NSString *)name {
    return [[[self alloc] initWithName:name number:nil] autorelease];
}
// 指派初始化方法
- (instancetype)initWithName:(NSString *)name number:(NSString *)number {
    self = [super init];
    if (self) {
        self.name = name;
        self.number = number;
    }
    return self;
}
+ (instancetype)AreaWithName:(NSString *)name number:(NSString *)number {
    return [[[self alloc] initWithName:name number:number] autorelease];

}
- (id)copyWithZone:(NSZone *)zone {
    District *dis = [[District allocWithZone:zone] init];
    dis.name = _name;
    dis.number = _number;
    return dis;
}
- (void)setName:(NSString *)name {
    if (_name != name) {
        [_name release];
        _name = [name copy];
    }
}
- (void)setNumber:(NSString *)number {
    if (_number != number) {
        [_number release];
        _number = [number copy];
    }
}
- (NSString *)description {
    return [NSString stringWithFormat:@"name:%@ number:%@", _name, _number];
}
- (void)dealloc {
    [_name release];
    [_number release];
    [super dealloc];
}
@end
